/*
 * miniFreeRTOS SOC System emulation.
 *
 * Copyright (c) 2024- yanl1229@163.com.
 * Written by yanl1229
 *
 * This code is licensed under the GPL.
 */
#ifndef LIST_H
#define LIST_H

#include <stddef.h>
#include <stdint.h>

/* 链表节点管理结构 */
struct list_node
{
    uint32_t value;                 /* 有序链表的键值 */
    struct list_node *next;        /* 后继节点 */
    void *priv;                    /* 保存私有数据 */
};

typedef struct list_node *list_head;

#define MAX_VALUE   0xffffffffUL

extern void list_init(list_head *list);
extern uint32_t get_value_of_first_entry(list_head list);
extern void *get_owner_of_first_entry(list_head list);
extern int list_count(list_head list);
extern int list_is_empty(list_head list);
extern void list_add_order(list_head list, struct list_node *entry);
extern void list_add_tail(list_head list, struct list_node *entry);
extern void list_remove(list_head list, struct list_node *entry);

#endif
